using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Configuration.Provider;
using AAM.BIZ;

namespace AAM.DAL
{
    public abstract class BizObjectProvider<T> : ProviderBase, BizObjectFinder<T>
    {
        public abstract T Read(ObjectID oid);
        public abstract List<T> ReadAll();
        public abstract bool Create(T obj);
        public abstract bool Update(T obj);
        public abstract bool Delete(ObjectID oid);

        #region BizObjectFinder<T> Members

        public T Find(ObjectID oid)
        {
            try
            {
                return (T)IdentityMap.Instance[oid];
            }
            catch (KeyNotFoundException)
            {
                return Read(oid);
            }
        }

        #endregion
    }
}
